package com.limou.service.impl;

import com.limou.mapper.UserMapper;
import com.limou.pojo.User;
import com.limou.pojo.UserQueryDTO;
import com.limou.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.bind.ValidationException;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User checkLogin(User user) {
        return userMapper.checkLogin(user);
    }

    @Override
    public User queryUserById(Integer id) {
        return userMapper.queryUserById(id);
    }

    // 注册
    @Override
    public void register(User user) {
        userMapper.saveUser(user);
    }

    // 在注册时，查看用户名是否重复
    @Override
    public User queryUserByUsername(String username) {
        return userMapper.queryUserByUsername(username);
    }

    @Override
    public int insert(User user) throws ValidationException {
        return userMapper.saveUser(user);
    }

    @Override
    public int delete(Integer id) throws ValidationException {
        return userMapper.delUser(id);
    }

    @Override
    public int updateData(User user) throws ValidationException {
        return userMapper.updateData(user);
    }

    @Override
    public List<User> getList(UserQueryDTO dto) throws ValidationException {
        return userMapper.getList(dto);
    }

}
